package com.candy.control;

import com.candy.bean.UserInfo;

import com.candy.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {
    @Autowired
    LoginService loginService;

    @RequestMapping("/")
    public String login(){
        return "index";
    }

    /**
     * 登录方法，返回结果为true，正常跳转页面，返回结果为false，跳转到之前登录页面
     * @param userInfo
     * @return
     */
    @RequestMapping("/logined")
    public String logined(UserInfo userInfo){
      boolean  ok=  loginService.logined(userInfo);
        System.out.println(ok);
      if(ok){
          return "pages/welcome";
      }else {
          return "index";
      }


    }





}
